package net.ufrog.common.converters;

/**
 * @author ultrafrog, ufrog.net@gmail.com
 * @version 0.1, 2017-07-07
 * @since 0.1
 */
public class BooleanConverter extends Converter<Boolean> {

    @Override
    public Boolean convert(Object obj, Object defaultValue) {
        if (obj != null) {
            return Boolean.valueOf(String.valueOf(obj));
        } else if (defaultValue != null) {
            return Boolean.valueOf(String.valueOf(defaultValue));
        } else {
            return null;
        }
    }

    @Override
    public Class<Boolean> getType() {
        return Boolean.class;
    }
}
